<?php

use think\migration\Migrator;
use think\migration\db\Column;

class WarningsItems extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('warnings_items', ['id'=>'id', 'comment'=>'预警项目表', 'engine'=>'innodb']);

        $table ->addColumn('content_type', 'string', ['length'=>10, 'comment'=>'预警内容类型, moisture:墒情, disaster:灾情', 'default'=>'moisture'])
               ->addColumn('content', 'text', ['comment'=>'预警内容'])
               ->addColumn('area_id', 'integer', ['length'=>10, 'comment'=>'适用地区id'])
               ->addColumn('crops_category_id', 'integer', ['length'=>10, 'comment'=>'适用品种id'])
               ->addColumn('range_cap', 'string', ['length'=>20, 'comment'=>'范围上限', 'default'=>'0'])
               ->addColumn('range_lower', 'string', ['length'=>20, 'comment'=>'范围下限', 'default'=>'0'])
               ->addColumn('important_range_cap', 'string', ['length'=>20, 'comment'=>'重要范围上限', 'default'=>'0'])
               ->addColumn('important_range_lower', 'string', ['length'=>20, 'comment'=>'重要范围下限', 'default'=>'0'])
               ->addColumn('unit', 'string', ['length'=>20, 'comment'=>'范围值单位 例: m/s', 'null'=>true])
               ->addTimestamps()
               ->create();

    }
}
